package com.delivery.www.service.ServiceImpl;

import com.delivery.www.dao.CommentDao;
import com.delivery.www.dao.DaoImpl.CommentDaoImpl;
import com.delivery.www.po.Comment;
import com.delivery.www.service.CommentService;
import com.delivery.www.util.JdbcUtils;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class CommentServiceImpl implements CommentService {
    private final CommentDao commentDao;

    public CommentServiceImpl() {
        commentDao = new CommentDaoImpl();
    }

    @Override
    public boolean doComment(int storeId, int userId, String content) {
        boolean flag = false;
        int i = commentDao.doComment(storeId, userId, content);
        if (i > 0) {
            flag = true;
        }
        return flag;
    }

    @Override
    public List<Comment> getComment(int storeId) {
        List<Comment> comments = null;
        comments = commentDao.getComment(storeId);
        return comments;
    }

    @Override
    public boolean deleteComment(int commentId, int storeId) {
        boolean flag = false;
        int i = commentDao.deleteComment(commentId, storeId);
        if (i > 0) {
            flag = true;
        }
        return flag;
    }
}
